package collection;

import java.util.ArrayList;
import java.util.List;

/**
 * 求子集
 * List 集合支持获取子集操作
 * Li
 */
public class ListDemo3 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0 ; i < 10 ; i++){
            list.add(i);
        }
        System.out.println(list);
        //获取[2-7]
        List<Integer> sublist = list.subList(2,8);//含头不含尾
        System.out.println(sublist);
        //将每个子集扩大十倍
        //[20,30,40,50,60,70]
        for (int i = 0; i < sublist.size(); i++) {
            int num = sublist.get(i);
            num = num * 10;
            sublist.set(i,num);
        }
        /*
        对子集的操作就是对原集对应的操作
         */
        System.out.println(list);
        //删除list集合中的1-8
        list.subList(1,9).clear();
        System.out.println(list);
    }
}
